<template>
	<van-form ref="form">
		<slot></slot>
	</van-form>
</template>
<script setup lang="ts">
import { Ref } from 'vue';
import { formProps } from './form';
const props = defineProps(formProps);
let form: Ref = ref(null);

const formValidate = async (name?: string): Promise<boolean> => {
	let validateResult: boolean = true;
	if (form.value && form.value.validate instanceof Function) {
		try {
			await form.value.validate(name);
		} catch (error) {
			validateResult = false;
		}
	}
	return validateResult;
};
defineExpose({ formValidate });
</script>
